package com.jeesite.modules.codingrule.entity;

import jakarta.validation.Valid;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import java.util.List;
import com.jeesite.common.collect.ListUtils;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

/**
 * 编码规则Entity
 * @author 码脑洞
 * @version 2025-04-13
 */
@Table(name="t_coding_rule_header", alias="a", label="编码规则信息", columns={
		@Column(name="auto_id", attrName="autoId", label="主键", isPK=true),
		@Column(name="org_id", attrName="orgId", label="组织ID", isQuery=false),
		@Column(name="org_code", attrName="orgCode", label="组织编码", isQuery=false),
		@Column(name="org_name", attrName="orgName", label="组织名称", isQuery=false),
		@Column(name="object_type", attrName="objectType", label="对象类型"),
		@Column(name="barcode_type", attrName="barcodeType", label="条码类型"),
		@Column(name="form_id", attrName="formId", label="表单ID", isUpdateForce=true),
		@Column(name="coding_type", attrName="codingType", label="编码方式", isQuery=false),
		@Column(name="coding_desc", attrName="codingDesc", label="编码示例", isQuery=false),
		@Column(includeEntity=DataEntity.class),
	}, orderBy="a.update_date DESC"
)
public class CodingRuleHeader extends DataEntity<CodingRuleHeader> {
	
	private static final long serialVersionUID = 1L;
	private Long autoId;		// 主键
	private Long orgId;		// 组织ID
	private String orgCode;		// 组织编码
	private String orgName;		// 组织名称
	private String objectType;		// 对象类型
	private String barcodeType;		// 条码类型
	private Long formId;		// 表单ID
	private String codingType;		// 编码方式
	private String codingDesc;		// 编码示例
	private List<CodingRuleLines> linesList = ListUtils.newArrayList();		// 子表列表

	public CodingRuleHeader() {
		this(null);
	}
	
	public CodingRuleHeader(String id){
		super(id);
	}
	
	@JsonSerialize(using = ToStringSerializer.class)
	public Long getAutoId() {
		return autoId;
	}

	public void setAutoId(Long autoId) {
		this.autoId = autoId;
	}
	
	@NotNull(message="组织ID不能为空")
	public Long getOrgId() {
		return orgId;
	}

	public void setOrgId(Long orgId) {
		this.orgId = orgId;
	}
	
	@NotBlank(message="组织编码不能为空")
	@Size(min=0, max=10, message="组织编码长度不能超过 10 个字符")
	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
	
	@NotBlank(message="组织名称不能为空")
	@Size(min=0, max=30, message="组织名称长度不能超过 30 个字符")
	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}
	
	@NotBlank(message="对象类型不能为空")
	@Size(min=0, max=10, message="对象类型长度不能超过 10 个字符")
	public String getObjectType() {
		return objectType;
	}

	public void setObjectType(String objectType) {
		this.objectType = objectType;
	}
	
	@Size(min=0, max=10, message="条码类型长度不能超过 10 个字符")
	public String getBarcodeType() {
		return barcodeType;
	}

	public void setBarcodeType(String barcodeType) {
		this.barcodeType = barcodeType;
	}
	
	public Long getFormId() {
		return formId;
	}

	public void setFormId(Long formId) {
		this.formId = formId;
	}
	
	@NotBlank(message="编码方式不能为空")
	@Size(min=0, max=1, message="编码方式长度不能超过 1 个字符")
	public String getCodingType() {
		return codingType;
	}

	public void setCodingType(String codingType) {
		this.codingType = codingType;
	}
	
	@Size(min=0, max=100, message="编码示例长度不能超过 100 个字符")
	public String getCodingDesc() {
		return codingDesc;
	}

	public void setCodingDesc(String codingDesc) {
		this.codingDesc = codingDesc;
	}
	
	@Valid
	public List<CodingRuleLines> getLinesList() {
		return linesList;
	}

	public void setLinesList(List<CodingRuleLines> linesList) {
		this.linesList = linesList;
	}
	
}